package edu.dublbo.app.generator.entity;

import edu.dublbo.app.generator.util.StrUtils;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;

/**
 * @author DubLBo
 * @since 2020-09-05 16:00
 * i believe i can i do
 */
@Getter
@Setter
public class TBasicModel implements Serializable {
    // 主键
    private String id;

    // 说明
    private String remark;
    // 表名称
    private String tableName;
    private Long sortNo;
    private String createUser;
    private Date createTime;
    private String modifyUser;
    private Date modifyTime;
    private Integer deleteFlag;

    // 模型名（不带包路径）
    private String modelName;

    private String busiName;

    /**
     * 默认自动生成的属性编号
     */
    private int[] defProNos;

    public TBasicModel() {}

    public static boolean checkValid(TBasicModel o) {
        return o != null
                && StrUtils.isValidClassName(o.getModelName())
                && !StrUtils.isEmpty(o.getRemark());
    }

    public static boolean checkValid1(TBasicModel o) {
        return o != null
                && StrUtils.isValidClassName(o.getModelName())
                && StrUtils.isEmpty(o.getRemark());

    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TBasicModel that = (TBasicModel) o;
        return id.equals(that.id);
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        return result;
    }

//    @Override
//    public String toString() {
//        return "TBasicModel{" +
//                "id='" + id + '\'' +
//                ", remark='" + remark + '\'' +
//                ", tableName='" + tableName + '\'' +
//                ", sortNo=" + sortNo +
//                ", deleteFlag=" + deleteFlag +
//                ", modelName='" + modelName + '\'' +
//                '}';
//    }

    public String toString() {
        return "TBasicModel{" +
                "id='" + id + '\'' +
                ", remark='" + remark + '\'' +
                ", tableName='" + tableName + '\'' +
                ", sortNo=" + sortNo +
                ", createUser='" + createUser + '\'' +
                ", createTime=" + createTime +
                ", modifyUser='" + modifyUser + '\'' +
                ", modifyTime=" + modifyTime +
                ", deleteFlag=" + deleteFlag +
                ", modelName='" + modelName + '\'' +
                ", busiName='" + busiName + '\'' +
                ", defProNos=" + Arrays.toString(defProNos) +
                '}';
    }
}
